import platform = require('../../../platform/common/baseCommon');
import bpCommon = require('../../../platform/common/bpCommon');
import appServer = require('../../../platform/server/appServer');
import appClient = require('../../../platform/client/appClient');
import { baseService } from '../../../platform/common/baseCommon';
import { debug } from 'util';
import { fileLogger } from '../../../platform/server/appServer';

const moduleName = "platform.server";

@platform.addon("纳税人信息服务", "纳税人信息服务", moduleName)
export class UserextendService extends baseService implements bpCommon.INsrxxService, platform.IFeatureSupport {
     /**
     * 特性控制器
     */
    featureController?: platform.baseFeatureController;
    /**
     * 根据usertoken查询纳税人信息
     * @param usertoken 
     */
    querytaxpayerinformation(usertoken: platform.userToken): Promise<platform.ResponseMessage<platform.userToken>> {
        let user = usertoken.userinfo;
        let rs = new platform.ResponseMessage<platform.userToken>();//返回对象
        let dataService: platform.IDataService = appServer.globalServices["webptDataService"];
        return dataService.query("cmd_user_nsrxx", { "ID": user.userId })//根据用户id查询关联的纳税人信息
        .then((table: platform.dataTable) => {
            table.rows.forEach(element => {
                let obj:Object =new Object();
                obj["djxh"] = element.rowValues["DJXH"];
                obj["nsrmc"] = element.rowValues["NSRMC"];
                obj["frsfz"] = element.rowValues["FDDBRSFZJHM"];
                obj["frxm"] = element.rowValues["FDDBRXM"];
                obj["nsrsbh"] = element.rowValues["NSRSBH"];
                obj["scjxdz"] = element.rowValues["SCJYDZ"];
                user.extrainfo=obj;
            });
            rs.body = usertoken;
            return rs;
        }).catch(error => {
           
            return rs;
        }); 
    }

}